home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 430_01 / m68kdis / mac / mac.pl < prev    next >
Encoding:
Perl Script  |  1994-12-29  |  1.9 KB  |  82 lines

  1. #!/usr/local/bin/perl
  2.  
  3. #                 Author:  Christopher G. Phillips
  4. #              Copyright (C) 1994 All Rights Reserved
  5. #
  6. #                              NOTICE
  7. #
  8. # Permission to use, copy, modify, and distribute this software and
  9. # its documentation for any purpose and without fee is hereby granted
  10. # provided that the above copyright notice appear in all copies and
  11. # that both the copyright notice and this permission notice appear in
  12. # supporting documentation.
  13. #
  14. # The author makes no representations about the suitability of this
  15. # software for any purpose.  This software is provided ``as is''
  16. # without express or implied warranty.
  17.  
  18. while (<>) {
  19.     if (/^(a([0189])[0-9a-fA-F]{2})\s+(.+)\s*$/) {
  20.         $s = $3;
  21.         $inst = $1;
  22.         $inst =~ tr/A-Z/a-z/;
  23.         $c = $2;
  24.         if ($c =~ /0/) {
  25.             $zero{"$inst"} = $s;
  26.         } elsif ($c =~ /1/) {
  27.             $one{"$inst"} = $s;
  28.         } elsif ($c =~ /8/) {
  29.             $eight{"$inst"} = $s;
  30.         } else {
  31.             $nine{"$inst"} = $s;
  32.         }
  33.     }
  34. }
  35.  
  36. foreach $key (sort byhex (keys %zero)) {
  37.     $key =~ /^a0(..)/ && ($last2 = $1);
  38.     $v = $zero{"$key"};
  39.     if (defined $one{"$key"}) {
  40.         for ($i = 0; $i < 8; $i += 2) {
  41.             print "a$i$last2 $v\n";
  42.         }
  43.         $v = $one{"$key"};
  44.         for ($i = 1; $i < 8; $i += 2) {
  45.             print "a$i$last2 $v\n";
  46.         }
  47.         undef $one{"$key"};
  48.     } else {
  49.         for ($i = 0; $i < 8; $i++) {
  50.             print "a$i$last2 $v\n";
  51.         }
  52.     }
  53. }
  54. foreach $key (sort byhex (keys %one)) {
  55.     $key =~ /^a1(..)/ && ($last2 = $1);
  56.     $v = $one{"$key"};
  57.     for ($i = 1; $i < 8; $i++) {
  58.         print "a$i$last2 $v\n";
  59.     }
  60. }
  61. foreach $key (sort byhex (keys %eight)) {
  62.     $key =~ /^a8(..)/ && ($last2 = $1);
  63.     $v = $eight{"$key"};
  64.     print "a8$last2 $v\n";
  65.     print "aa$last2 $v\n";
  66.     print "ac$last2 $v\n";
  67.     print "ae$last2 $v\n";
  68. }
  69. foreach $key (sort byhex (keys %nine)) {
  70.     $key =~ /^a9(..)/ && ($last2 = $1);
  71.     $v = $nine{"$key"};
  72.     print "a9$last2 $v\n";
  73.     print "ab$last2 $v\n";
  74.     print "ad$last2 $v\n";
  75.     print "af$last2 $v\n";
  76. }
  77. exit(0);
  78.  
  79. sub byhex {
  80.     hex($a) - hex($b);
  81. }
  82.